package com.doubao.wechat.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain;

/**
 * 微信支付服务安全配置
 * 临时禁用对支付接口的认证，方便本地开发调试
 */
@Configuration
@EnableWebSecurity
public class SecurityConfig {

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http
            .csrf(csrf -> csrf.disable())
            .authorizeHttpRequests(authorize -> authorize
                // 微信支付相关接口临时允许匿名访问
                .requestMatchers("/wechat/pay/**").permitAll()
                // 其他接口保持现有配置
                .anyRequest().permitAll()
            );
        
        return http.build();
    }
} 